<?php
class RoomFacility extends RoomFacilityPeer
{
	function RoomFacility()
	{
		parent::RoomFacilityPeer();
	}
	
	public static function getAllFacilitiesForRoom($room_id)
	{
		$db = new Database();
		$query = "SELECT facility_id FROM room_facility WHERE room_id = ".$room_id;
		$db->query($query);
		$ids = $db->fetch_array($db->result);
		$facilities = array();
		if ($ids)
			foreach ($ids as $id) {
				$facility = new Facility();
				$facility->select($id['facility_id']);
				$facilities[] = $facility;
			}
			
		return $facilities;
	}
	
	
	public static function retriveByHotelIdAndFacilityId($room_id, $facility_id)
	{
		$db = new Database();
		$query = "SELECT id FROM room_facility WHERE room_id = $room_id AND facility_id = $facility_id";
		$db->query($query);
		$id = $db->result;
		$id = mysql_fetch_row($id);
		if (isset($id[0])) {
			$id = $id[0];
			$room_facility = new RoomFacility();
			$room_facility->select($id);
			return $room_facility;
		}
		return null;
	}
}
?>